﻿//**********************************************************
//Copyright(C)2010 By 波特商网公司 版权所有。
//
//文件名：
//文件功能：我的帐号信息
//
//创建标识：齐李平 || 2011-03-24
//
//修改标识：
//修改描述：
//**********************************************************

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Hmc.IM.Common.Base;
using Hmc.IM.Common.Forms;
using Hmc.IM.Common;

namespace Hmc.IM.Client
{
    /// <summary>
    /// 我的帐号信息
    /// </summary>
    public partial class MyAccoutForm : FrameForm
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MyAccoutForm()
        {
            PowerId = 0;
            InitializeComponent();
        }

        /// <summary>
        /// 加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MyAccoutForm_Load(object sender, EventArgs e)
        {
            InitData();
        }

        private void InitData()
        {
            //List<ViewSystemUserDepartmentEntity> list = null;
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += (sender, e) =>
                {
                    //try
                    //{
                    //    ServiceInvokeHelper<StoreContractsClient>.Invoke(db =>
                    //                    {
                    //                        e.Result = db.GetSystemUserBySystemUserId(LoginUserEntity.Token, LoginUserEntity.SystemUserId);
                    //                        list = db.GetSystemUserDepartmentListBySystemUserId(LoginUserEntity.Token, LoginUserEntity.SystemUserId);
                    //                    });
                    //}
                    //catch (Exception ex)
                    //{
                    //    e.Result = ex;
                    //}
                };
            worker.RunWorkerCompleted += (sender, e) =>
                {
                    if (e.Result is Exception)
                    {
                        //Recorder.Write((e.Result as Exception));
                        MessageBox.Show((e.Result as Exception).Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else if(e.Result != null)
                    {
                        //SystemUserEntity entity = e.Result as SystemUserEntity;
                        //txtUserName.Text = entity.UserName;
                        //txtRealName.Text = entity.RealName;
                        //lbEmployeeId.Text = entity.EmployeeId;
                        //lbRole.Text = entity.RoleName;
                        //txtStatus.Text = EnumHelper.GetDescriptionByValue(typeof(EnumSystemUserStatus),entity.Status);
                        //StringBuilder str = new StringBuilder();
                        //foreach (ViewSystemUserDepartmentEntity item in list)
                        //{
                        //    str.Append(string.Format("{0},", item.DepartmentName));
                        //}
                        //lbClass.Text = str.ToString().Trim(',');
                    }
                };
            worker.RunWorkerAsync();
        }

    }
}
